package com.yoomiito.app.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.jakewharton.rxbinding3.view.RxView;
import com.yoomiito.app.R;
import com.yoomiito.app.model.bean.AppInterfaceInfo;
import com.yoomiito.app.model.bean.OrderInfo;
import com.yoomiito.app.utils.AllUtils;
import com.yoomiito.app.utils.ImageLoader;
import com.yoomiito.app.utils.SpannableUtils;
import com.yoomiito.app.utils.wx.WXUtils;
import com.yoomiito.app.widget.SelectView;

import java.util.concurrent.TimeUnit;

public class StockDialog extends BaseDialog implements View.OnClickListener {
    private final int MONEY_PAY = 1;
    private final int WX_PAY = 2;
    private final int ALI_PAY = 3;
    private final int MONEY_WX_PAY = 4;
    private final int MONEY_ALI_PAY = 5;
    private final int OFFLINE = 6;

    private OnResultListener mOnResultListener;


    private String balance = "";//余额
    private String payMoney = "";//待支付
    private boolean radio;//
    private boolean isMoneyPay = true;
    TextView orderIdTv;
    TextView goodsSize;

    AppInterfaceInfo appInterfaceInfo;
    private LinearLayout llWx, llZfb, llOffline;
    OrderInfo orderList;
    ImageView goodsPicIv;
    TextView goodsTitleTv;
    TextView mobile;
    TextView orderDateTv;
    TextView tvNum;
    TextView priceTv;

    public StockDialog(@NonNull Context context) {
        this(context, 0);
    }

    public StockDialog(@NonNull Context context, int themeResId) {
        super(context, R.style.dialog_2);
    }

    @Override
    public View setView() {
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_stock, null, false);
        orderIdTv = view.findViewById(R.id.item_goods_order_id);
        goodsSize = view.findViewById(R.id.item_goods_order_size);
        goodsPicIv = view.findViewById(R.id.item_goods_order_pic);
        goodsTitleTv = view.findViewById(R.id.item_goods_order_title);
        mobile = view.findViewById(R.id.item_mobile);
        orderDateTv = view.findViewById(R.id.item_goods_order_date);
        tvNum = view.findViewById(R.id.tv_num);
        priceTv = view.findViewById(R.id.item_goods_order_price);
        setData();
        view.findViewById(R.id.iv_accept).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        setWidthPercent(1);
        setmGravity(Gravity.BOTTOM);
        return view;
    }

    @Override
    public void onBackPressed() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.pay:
                if (AllUtils.isFastClick()) {
                    return;
                }
                break;
        }

    }

    void setData(){
        if (orderList != null) {
            if (orderIdTv != null)
                orderIdTv.setText("订单号：" + orderList.getId());
            if (goodsSize != null)
                goodsSize.setText("实付金额: ");
            //商品图
            if (goodsPicIv != null)
                ImageLoader.getInstance().into(mContext, orderList.getItem_picture(), goodsPicIv, R.drawable.goods_default);
            //商品title
            if (goodsTitleTv != null)
                goodsTitleTv.setText("用户姓名：" + orderList.userName);
            if (mobile != null)
                mobile.setText("手机号码：" + orderList.mobile);
            //订单时间
            if (orderDateTv != null)
                orderDateTv.setText(orderList.getCtime());
            if (tvNum != null)
                tvNum.setText(orderList.getNum() + "");
            //订单价格
            if (priceTv != null)
                priceTv.setText("¥" + orderList.money);
        }
    }

    public void setOnResultListener(OnResultListener onResultListener) {
        mOnResultListener = onResultListener;
    }

    public void setData(OrderInfo orderList) {
        this.orderList = orderList;
        setData();
    }

    public interface OnResultListener {
        void onResult(int moneyPay, int wxPay, int aliPay, int offline, boolean dismiss);
    }


    public void setShow(AppInterfaceInfo appInterfaceInfo) {
        this.appInterfaceInfo = appInterfaceInfo;
        if (llZfb == null || llWx == null || llOffline == null)
            return;

    }


}
